package com.wpg.demo.spring.xml;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ChangWei Li
 * @version 2017-02-22 09:20
 */
@Configuration
@PropertySource("classpath:jdbc.properties")
public class PropertiesConfig {

    private final Environment env;

    public PropertiesConfig(Environment env) {
        this.env = env;
    }

    @Bean
    public Map<String, String> globalConfig() {
        Map<String, String> result = new HashMap<>();
        result.put("username", env.getProperty("jdbc.user"));
        result.put("password", env.getProperty("jdbc.pass"));

        return result;
    }

}
